<?php
/*
* File：添加用户
* Author：易如意
* QQ：51154393
* Url：www.eruyi.cn
*/

require_once 'globals.php';
include_once 'header.php';
$user = isset($_POST['user']) ? addslashes($_POST['user']) : '';
$password = isset($_POST['password']) ? addslashes($_POST['password']) : '';
$superpass = isset($_POST['superpass']) ? addslashes($_POST['superpass']) : '';
$money = isset($_POST['money']) ? intval($_POST['money']) : 0;
$regdate = time();
$regip = isset($_POST['regip']) ? addslashes($_POST['regip']) : '';
$markcode = isset($_POST['markcode']) ? addslashes($_POST['markcode']) : '';
if($user != '' && $password != '' && $superpass != ''){
	$sql="select * from eruyi_user where user='$user'";
	$query=$db->query($sql);
	$have=$db->fetch_array($query);
	if($have){
		echo "<script>alert('失败：用户名已存在');</script>";
	}else{
		$pass = md5($password);
		$sql="INSERT INTO `eruyi_user`(`user`, `password`, `superpass`, `money`, `regdate`, `regip`, `markcode`,`lock`) VALUES ('$user','$pass','$superpass','$money','$regdate','$regip','$markcode','n')";
		$query=$db->query($sql);
		if($query){
			echo "<script>alert('添加成功');</script>";
		}
	}
}
?>
<form action="" method="post" id="addimg" name="addimg">
<div id="post">
<div>
    <label for="user" id="user_label">用户账号：</label>
    <input type="text" maxlength="200" name="user" value="" id="user"/> *
</div>
<div>
    <label for="password" id="password_label">用户密码：</label>
    <input type="text" maxlength="200" name="password" value="" id="password"/> *
</div>
<div>
    <label for="superpass" id="superpass_label">超级密码：</label>
    <input type="text" maxlength="200" name="superpass" value="" id="superpass"/> *
</div>
<div>
    <label for="money" id="money_label">账户余额：</label>
    <input type="text" maxlength="200" name="money" value="0" id="money"/>
</div>
<div>
    <label for="regip" id="regip_label">注册 I P：</label>
    <input type="text" maxlength="200" name="regip" value="" id="regip"/>
</div>
<div>
    <label for="markcode" id="markcode_label">注册机器：</label>
    <input type="text" maxlength="200" name="markcode" value="" id="markcode"/>
</div>
<div id="post_button">
    <input type="submit" name="submit" value="添加用户" class="button" />
</div>
</div>
</form>
<script> 
var div = document.getElementById('add_user'); 
div.setAttribute("class", "show"); 
</script> 
<?php 
include_once 'footer.php';
?>